package com.bluefish.bltuan.action;

import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;

import com.bluefish.bltuan.module.cms.Content;
import com.bluefish.bltuan.service.ContentService;

public class CmsAction extends OpenAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1893700819857912792L;
	
	private Content content;
	
	private ContentService contentService;
	
	@Override
	public HttpHeaders show() {
		String nick = this.getId();
		this.content = this.contentService.getByNick(nick);
		if(!this.content.isLink())
			return new DefaultHttpHeaders(SHOW).disableCaching();
		else{
			redirectTo(this.content.getWebsite());
			return null;
		}
	}
	
	@Override
	public HttpHeaders index() {
		return new DefaultHttpHeaders(INDEX).disableCaching();
	}
	
	public void setContentService(ContentService contentService) {
		this.contentService = contentService;
	}
	
	public Content getContent() {
		return content;
	}

}
